﻿using Windows.UI;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Media;
using Windows.UI.Xaml.Shapes;

namespace PanViewDemoApp
{
    public sealed partial class MainPage : Page
    {
        public MainPage()
        {
            this.InitializeComponent();
            SizeChanged += OnSizeChanged;
        }

        void OnSizeChanged(object sender, SizeChangedEventArgs args)
        {
            DrawLines(args.NewSize.Height, args.NewSize.Width);
        }

        private void DrawLines(double height, double width)
        {
            var brush = new SolidColorBrush(Colors.Red);

            _grid.Children.Clear();

            for (var y = 0; y < height; y += 100)
            {
                _grid.Children.Add(new Line { X1 = 0, X2 = width, Y1 = y, Y2 = y, Stroke = brush });
            }
            for (var x = 0; x < width; x += 100)
            {
                _grid.Children.Add(new Line { X1 = x, X2 = x, Y1 = 0, Y2 = height, Stroke = brush });
            }
        }

        private void OnResetClicked(object sender, RoutedEventArgs e)
        {
            MyPanView.Reset();
        }
    }
}
